home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snip0493.zip / HSTR_I.C < prev    next >
C/C++ Source or Header  |  1993-04-05  |  625b  |  31 lines

  1. /*
  2. **  Originally published as part of the MicroFirm Function Library
  3. **
  4. **  Copyright 1986, S.E. Margison
  5. **  Copyright 1989, Robert B.Stout
  6. **
  7. **  Subset version released to the public domain, 1992
  8. **
  9. **  Make an ascii hexadecimal string into an integer.
  10. */
  11.  
  12. #include <stdio.h>
  13. #include <ctype.h>
  14.  
  15. #define NUL '\0'
  16.  
  17. unsigned int hstr_i(char *cptr)
  18. {
  19.       unsigned int i, j = 0;
  20.  
  21.       while ((NUL != *cptr) && isxdigit(*cptr))
  22.       {
  23.             i = *cptr++ - '0';
  24.             if (9 < i)
  25.                   i -= 7;
  26.             j <<= 4;
  27.             j |= (i & 0x0f);
  28.       }
  29.       return(j);
  30. }
  31.